package com.huaweicloud.persistent.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.huaweicloud.common.Contants;
import com.huaweicloud.commons.pojo.User;
import com.huaweicloud.persistent.entity.CoCompany;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * Mapper类
 */
@Mapper
public interface CoCompanyMapper extends BaseMapper<CoCompany> {
    @Select("<script> CREATE DATABASE IF NOT EXISTS ${dataBaseName} </script>")
    void createCompanyDataBase(@Param("dataBaseName") String dataBaseName);

    @Select(Contants.USER_TABLE_TEMPLATE)
    void createCompanyTable(@Param("schemeName") String schemeName, @Param("tableName") String tableName);

    @Select("<script> select TABLE_NAME from information_schema.TABLES " +
            " where TABLE_NAME = #{tableName} and TABLE_SCHEMA = #{schemeName} </script>")
    String findTableName(@Param("tableName") String tableName, @Param("schemeName") String schemeName);
}
